package com.cbb.admin.cbb;

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;

import com.android.volley.toolbox.NetworkImageView;
import com.cbb.net.HttpLoad;
import com.cbb.utils.SharedPre;
import com.cbb.utils.SharedPreUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

public class StartActivity extends BaseActivity implements Animation.AnimationListener, View.OnClickListener {

    @BindView(R.id.start_page)
    NetworkImageView startPage;
    private ProgressDialog m_progressDlg;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        AlphaAnimation animation = new AlphaAnimation(0.8f, 1.0f);
        animation.setDuration(2000);
        animation.setAnimationListener(this);
        startPage.startAnimation(animation);
        m_progressDlg = new ProgressDialog(this);
        m_progressDlg.setCancelable(false);
        m_progressDlg.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        // 设置ProgressDialog 的进度条是否不明确 false 就是不设置为不明确
        m_progressDlg.setIndeterminate(false);
        //  m_mainHandler = new Handler();

    }

    @Override
    public void onClick(View view) {

    }

    @Override
    public void onAnimationStart(Animation animation) {
        setView();
    }
    private void setView() {
        HttpLoad.getImage(this, SharedPreUtils.getString
                (mContext, SharedPre.App.START_IMAGE), R.mipmap.guide, startPage);
    }
    @Override
    public void onAnimationEnd(Animation animation) {
        enter();

    }

    @Override
    public void onAnimationRepeat(Animation animation) {

    }

    private void enter() {
      /*  boolean isGuide = SharedPreUtils.getBoolean(this, SharedPre.App.ISGUIDE, false);
        Intent intent = new Intent(StartActivity.this, isGuide ? MainActivity.class :
                GuideActivity.class);*/
     /*   String tokenId = SharedPreUtils.getString(mContext, SharedPre.User.TOKEN_ID);
        if(tokenId == null || tokenId.equals("")){
            Intent intent = new Intent(StartActivity.this, LoginActivity.class);
            startActivity(intent);
        }else{
            Intent intent = new Intent(StartActivity.this,  MainActivity.class);
            startActivity(intent);
        }
        StartActivity.this.finish();*/
        Intent intent = new Intent(StartActivity.this,  MainActivity.class);
        startActivity(intent);
    }
}
